home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / SFP2TFP < prev    next >
Encoding:
Text File  |  1985-12-25  |  2.3 KB  |  69 lines

  1. ;-------------------------sfp2tfp routine begins--------------------------+
  2. ; ROUTINE FOR CONVERSION FROM SINGLE PRECISION TO TEMPORARY FLOATING POINT
  3. ;
  4. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  5. ;         page : 93
  6. ;
  7. ; NAME SFP2TFP
  8. ;
  9. ; FUNCTION: This routine converts from single precision binary floating point
  10. ; to temporary binary floating point.
  11. ;
  12. ; INPUT: Upon entry a number is stored in single precision binary floating
  13. ; point form in SFPBUFF. The single precision binary floating point number
  14. ; has a 24-bit binary mantissa, a sign bit, and an 8-bit exponent biased by
  15. ; 128 (See fig 5-3).
  16. ;
  17. ; OUTPUT: Upon exit a temporary binary floating point number is stored in
  18. ; FPTEMP1.  The temporary binary floating point number has a 72-bit binary
  19. ; mantissa with 8 bits to the left of those for internal use, a sign byte,
  20. ; and an 16-bit two's complement exponent (See fig 5-2).
  21. ;
  22. ; REGISTERS USED:  AX is modified.
  23. ;
  24. ; SEGMENTS REFERENCED:  Upon entry the data segment must contain the
  25. ; storage for the temporary binary floating point number FPTEMP1 and the
  26. ; temporary binary floating point number SFPBUFF.
  27. ;
  28. ; ROUTINES CALLED:  None
  29. ;
  30. ; SPECIAL NOTES: Equates are used to shorten address fields.  This is a
  31. ; near procedure needed by FPOUT.  Include the file FPCEQU_S at assembly.
  32. ;
  33. ; ROUTINE TO CONVERT FROM SINGLE PRECISION FLOATING POINT TO
  34. ; TEMP FLOATING POINT
  35. ;
  36. sfp2tfp proc    near
  37. ;
  38. ; clear lower part of mantissa
  39.     mov    fptemp1w0,0    ; clear word
  40.     mov    fptemp1w2,0    ; clear word
  41.     mov    fptemp1w4,0    ; clear word
  42. ;
  43. ; move rest of mantissa
  44.     mov    ax,sfpbuffw0    ; low two bytes
  45.     mov    fptemp1w6,ax    ; put in place
  46. ;
  47.     mov    ax,sfpbuffw2    ; 7 hi bits
  48.     and    ax,07Fh        ; remove sign
  49.     or    ax,0080h    ; restore msb
  50.     mov    fptemp1w8,ax    ; put in place
  51. ;
  52. ; move sign
  53.     mov    al,sfpbuffb2    ; in upper byte
  54.     and    al,80h        ; just sign bit
  55.     mov    fptemp1b10,al    ; byte 10 of fptemp1
  56. ;
  57. ;
  58. ; move exponent
  59.     mov    al,sfpbuffb3    ; byte three of sfp
  60.     mov    ah,0        ; make into a word
  61.     sub    ax,80h        ; remove bias
  62.     mov    fptemp1w11,ax    ; it's 16-bit 2's complement
  63. ;
  64.     ret            ; return
  65. ;
  66. sfp2tfp    endp
  67. ;-------------------------sfp2tfp routine ends---------------------------+
  68.  
  69.